<template>
  <div class="award-wrap">
    <div class="bg-box"></div>
    <div class="entry-box">
      <div class="title-box">
        <div class="line-box"></div>
        <div class="title">邀请入职奖励</div>
        <div class="back-box" @click="toPage"><span class="detail">查看详情</span><img src="./back.png" class="back"/></div>
      </div>
      <div class="entry-content">
        <div class="entry-num">
          <div class="number">{{directNum}}人</div>
          <div class="title">直接邀请人</div>
        </div>
        <div class="line"></div>
        <div class="entry-num">
          <div class="number">{{indirectNum}}人</div>
          <div class="title">间接邀请人</div>
        </div>
      </div>
    </div>

    <div class="price-box">
      <div class="title-box">
        <div class="line-box"></div>
        <div class="title">邀请注册奖励</div>
      </div>
      <div class="prize-con">
        <div class="prize-num">
          <div class="number">{{sumNum}}人</div>
          <div class="title">邀请注册人数</div>
        </div>
        <div class="line"></div>
        <div class="prize-num">
          <div class="number">{{sumNum * 20}}元</div>
          <div class="title">注册奖励金</div>
        </div>
      </div>
      <div class="prize-con">
        <div class="prize-num">
          <div class="number">{{noneMoney}}元</div>
          <div class="title">未到账注册奖励</div>
        </div>
        <div class="line"></div>
        <div class="prize-num">
          <div class="number">{{arriveMoney}}元</div>
          <div class="title">到账注册奖励</div>
        </div>
      </div>
    </div>

    <div class="title-box">
      <div class="line-box"></div>
      <div class="title">奖励规则:</div>
    </div>
    <div class="rule-box">
      <div class="rule-con">
        <p>1.用户每邀请一个员工注册，当被邀请人通过本平台成功入职满一个月后,邀请人便能获取20元奖励。</p>
        <p>2.用户每邀请一个员工通过本平台成功入职,工作每满一个月,用户便能获取80元奖励金,奖励期限由入职企业决定。</p>
        <p>3.用户的被邀请人每邀请一个员工通过本平台成功入职，工作每满一个月,用户便能获取50元奖励金，奖励期限由入职企业决定。</p>
        <p>4.本活动最终解释权归蓝聘平台所有!</p>
      </div>
    </div>
  </div>
</template>

<script>
  import {baseUrl} from "../../common/js/env";

  export default {
    data() {
      return {
        userSign: "",
        directNum: "",
        indirectNum: "",
        sumNum: "",
        fullNum: "",
        arriveMoney: "",
        noneMoney: ""
      }
    },
    mounted() {
      let base64 = require('js-base64').Base64;
      this.userSign = base64.decode(sessionStorage.getItem("user_sign"));
      this.getRegister();
    },
    methods: {
      toPage() {
        this.$router.push("/awarddetail");
      },
      getRegister() {//获取邀请注册、入职人数
        this.$vux.loading.show({
          text: '加载中',
        });
        this.axios.get(baseUrl + "/invite/get_register?sgin=" + this.userSign).then((res) => {
          let billObj = res.data;
          this.$vux.loading.hide();
          if (billObj.code == 0) {
            this.directNum = billObj.data.BUserNum;//直接邀请人数
            this.indirectNum = billObj.data.CUserNum;//间接邀请人数
            this.sumNum = billObj.data.sumNum;//邀请的总注册人数
            this.fullNum = billObj.data.fullMonthNum;//邀请注册已到账人数
            this.arriveMoney = parseInt((this.sumNum * 20 - this.fullNum * 20));//已到金额
            this.noneMoney = parseInt(this.sumNum * 20 - this.arriveMoney);
          } else {
            this.$vux.toast.text(billObj.msg, "middle");
          }
        }).catch(() => {
          this.$vux.loading.hide();
          this.$vux.toast.text("网络异常", "middle");
        });
      }
    }
  }
</script>

<style lang="stylus" scoped>
  @import "../../common/stylus/mixin.styl"

  .award-wrap
    wh(100%, auto)
    .bg-box
      wh(100%, 3.52rem)
      bg-image("./award.png", 100%, 100%)
      margin-bottom: 0.4rem
    .entry-box
      margin: 0 auto
      margin-bottom: 0.573rem
      wh(92.53%, 2.813rem)
      .title-box
        fj(center, center)
        margin-bottom: 0.293rem
        wh(100%, 0.44rem)
        .line-box
          margin-right: 0.08rem
          wh(0.067rem, 0.413rem)
          background: rgba(73, 180, 254, 1)
          border-radius(0.027rem)
        .title
          size-color(0.44rem, rgba(27, 27, 27, 1))
        .back-box
          display: flex
          align-items: center
          margin-left: auto
          .detail
            margin-right: 0.08rem
            size-color(0.333rem, rgba(60, 175, 255, 1))
          .back
            wh(0.2rem, 0.32rem)
      .entry-content
        display: flex
        align-items: center
        wh(100%, 2.067rem)
        background: rgba(60, 175, 255, 1)
        border-radius: 0.133rem
        .line
          wh(0.013rem, 1.387rem)
          border: 0.013rem solid rgba(238, 238, 238, 1);
        .entry-num
          flex: 1
          text-align: center
          .number
            padding-bottom: 0.12rem
            size-color(0.44rem, rgba(255, 255, 255, 1))
            font-weight: bold
          .title
            padding-top: 0.12rem
            size-color(0.387rem, rgba(242, 242, 242, 1))
    .price-box
      margin: 0 auto
      margin-bottom: 0.573rem
      wh(92.53%, 4.12rem)
      .title-box
        fj(flex-start, center)
        margin-bottom: 0.28rem
        wh(100%, 0.44rem)
        .line-box
          margin-right: 0.08rem
          wh(0.067rem, 0.413rem)
          background: rgba(255, 102, 102, 1)
          border-radius(0.08rem)
        .title
          size-color(0.44rem, rgba(27, 27, 27, 1))
      .prize-con
        display: flex
        margin-bottom: 0.067rem
        wh(100%, 1.667rem)
        .prize-num
          display: flex
          flex-direction: column
          justify-content: center
          flex: 1
          text-align: center
          background: rgba(255, 227, 227, 1)
          border-radius(0.08rem)
          .number
            padding-bottom: 0.08rem
            size-color(0.387rem, rgba(255, 102, 102, 1))
          .title
            padding-top: 0.08rem
            size-color(0.387rem, rgba(68, 68, 68, 1))
        .line
          wh(0.067rem, 100%)
    .title-box
      fj(flex-start, center)
      margin: 0 auto
      margin-bottom: 0.293rem
      wh(92.53%, 0.44rem)
      .line-box
        margin-right: 0.08rem
        wh(0.067rem, 0.413rem)
        background: rgba(73, 180, 254, 1)
        border-radius(0.027rem)
      .title
        size-color(0.44rem, rgba(27, 27, 27, 1))
    .rule-box
      margin: 0 auto
      margin-bottom: 0.4rem
      wh(92.53%, 5.347rem)
      background: rgba(73, 180, 254, 1)
      border-radius(0.133rem)
      .rule-con
        margin: 0 auto
        padding-top: 0.4rem
        wh(94%, 4.52rem)
        p
          size-color(0.373rem, rgba(255, 255, 255, 1))
          line-height: 0.52rem
</style>
